<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>最大公约数</title>
</head>
<body>
    <script>

        var num1 = 1230;
        var num2 = 600;
        // 最小值
        var minNum;
        // 最大公约数
        var maxCom;

        //比较大小
        num1>num2?minNum=num2:minNum=num1;

        for(var i=1;i<minNum;i++){

            //是否都是取余为0
            if(num1%i == 0 && num2%i ==0){
                //若是，则写入maxCom
                maxCom = i;
                console.log(maxCom);
            }
        }
        console.log(num1 + '和'+ num2 +'的最大公约数',maxCom);


    </script>
</body>
</html>